
$(function(){
    $("#UpDictionary").dialog({
        title:"修改物资字典",
        btnName:"修改",
        btnBind:function(){
            var params=$("#updateDictionary").serializeArray();
            var param="";
            for(var i in params){

                if(i==params.length-1){
                    param+=params[i].name+"="+params[i].value;
                }else{
                    param+=params[i].name+"="+params[i].value+"&";
                }
            }
            console.info(param)


            $.post("base/dictionary/updateDictionary",param,function (msg) {
                $("#UpDictionary").dialog("close");
                $("#table").bootstrapTable("refresh");
                toastr.warning("信息提示",msg);
            },"text")
        }
    });

    $("#AddDictionary").dialog({
        title:"添加",
        btnName:"添加",
        btnBind:function(){
            var params=$("#adDictionary").serializeArray();
            var param="";
            for(var i in params){

                if(i==params.length-1){
                    param+=params[i].name+"="+params[i].value;
                }else{
                    param+=params[i].name+"="+params[i].value+"&";
                }
            }
            console.info(param)


            $.post("base/dictionary/addDictionary",param,function (msg) {
                $("#AddDictionary").dialog("close");
                $("#table").bootstrapTable("refresh");
                toastr.warning("信息提示",msg);
            },"text")
        }
    });
});


function FormatOperation(value,row,index){
    var peration = "<span class='btn btn-default' onclick='updateDictionary("+JSON.stringify(row)+")'><i class='glyphicon glyphicon-edit'></i>详情</span>";
    return peration;
}

function addDictionary() {
    $(".modal .modal-body #AddDictionary").attr("class","show");
    $("#AddDictionary").dialog("open");
}

function  updateDictionary(row) {
   console.info(row)
    $("#updateDictionary").setForm(row);


    $(".modal .modal-body #UpDictionary").attr("class","show");
    $("#UpDictionary").dialog("open");
    console.info(row);
}


function searchTjDictionary() {
    var param=$("#condition").serializeArray();
    console.info(param)

    var obj={};
    for(var i in param){
        obj[param[i].name]=param[i].value;
    }
    $("#table").bootstrapTable("refresh",{query:obj});

}

function FormatGooall(val,row,index){
    var name=null;
    $.ajax({
        url:'base/goodsSort/searchByGoodsSort',
        data:"id="+val,
        dataType:'json',
        type:'post',
        async:false,
        success:function (result) {
            name= result.gooallName;
        }
    });
    return name;
}